
/////////////////////////////////////////////////
//
//              GLOBAL VARIABLES 
//
/////////////////////////////////////////////////

var _uploadimage = false;
var _uploadfile = false;

/////////////////////////////////////////////////
//
//                  FUNCTIONS
//
/////////////////////////////////////////////////


/**************************************
*
*             $ startUpload
*
***************************************/
function startUpload()
{
	$('#uploadify').uploadifyUpload();
	alert("Bem vindo a minha pagina");
};// startUpload

/**************************************
*
*        $ setUploadImageTrue
*
***************************************/
function setUploadImageTrue()
{
	_uploadimage = true; 
	alert(_uploadimage);
};// startUpload

/**************************************
*
*        $ setUploadFileTrue
*
***************************************/
function setUploadFileTrue()
{
	 _uploadfile = true;
	 alert(_uploadfile);
};// startUpload

/**************************************
*
*        $ checkUploadImage
*
***************************************/
function checkUploadImage()
{
	  var ext = document.uploadForm.uploadimage.value;
	  if( ext == "")
	  {		  
		  return false;
	  }	  
	  
	  ext = ext.substring(ext.length-3,ext.length);
	  ext = ext.toLowerCase();
	  if(ext != 'jpg') 
	  {	     
	     return false; 
	  }
	  else
	    return true; 
};// checkUploadImage

/**************************************
*
*        $ checkUploadFile
*
***************************************/
function checkUploadFile()
{
	  var ext = document.uploadForm.uploadfile.value;
	  if( ext == "")
	  {		  
		  return false;
	  }		  
	  else
	    return true; 
};// checkUploadFile


/**************************************
*
*             $ checkForm
*
***************************************/
function checkForm()
{
	var text = "";
	var condRet; // The function return value.
	
	// Titulo
	text = $('input#titulo').val();
	if( text == "")
	{
		alert("Por favor, escreva o Titulo.");
		return;
	}
	
	// Type
	text = $('select#artifactstype').val();	
	if( text == "Tipo de Artefato")
	{
		alert("Por favor, escolha um tipo de artefato.");
		return;
	}
	
	
	// TextArea
	text = $('textarea#texto').val();
	if( text == "")
	{
		alert("Por favor, escreva a explicação do artefato.");
		return;
	}
	
	// UPLOADIMAGE 
	condRet = checkUploadImage();
	if ( condRet == false)
	{
		alert("Por favor, escolher uma imagem jpeg.");
		return;
	}
	
		
	// UPLOADFILE
	condRet = checkUploadFile();
	if( condRet == false )
	{
		alert("Por favor, escolher o arquivo do artefato.");
		return;
	}
		
};// checkForm